package com.explorati.interview.interview.chapterfifteen;

public class NineNineMultiTable {

	public static void main(String[] args) {
		printNineNineMultiTable1();
	}

	public static void printNineNineMultiTable() {
		for (int i = 1; i < 10; i++) {
			int j = 1;
			// i是主控， j小于i时j++
			while (j <= i) {
				System.out.print(j + " * " + i + "=" + j * i + "\t");
				// if (i * j < 10) {
				// System.out.print(" ");
				// }
				j++;
			}
			System.out.println();
		}
	}

	public static void printNineNineMultiTable1() {
		for (int i = 1, j = 1; j <= 9; i++) {
			System.out.print(i + " * " + j + " = " + i * j);
			if (i * j >= 10) {
				System.out.print("  ");
			} else {
				System.out.print("   ");
			}
			// 只有i==j时j才+1，之前i不知道循环了多少遍，所以i得置0
			if (i == j) {
				j++;
				i = 0;
				System.out.println();
			}
		}
	}
}
